//
//  LNHomeThemeCell.m
//  LNDevelopExample
//
//  Created by wwww on 2018/9/28.
//  Copyright © 2018年 淘发现1iOS. All rights reserved.
//

#import "LNHomeThemeCell.h"
#import "LNHomeThemeItem.h"

@interface LNHomeThemeCell()

@property (nonatomic,strong) UIView *bgContentView;

@end

@implementation LNHomeThemeCell

-(instancetype)initWithFrame:(CGRect)frame{
    
    self = [super initWithFrame:frame];
    if(self){
        [self setupUI];
    }
    return self;
}

#pragma mark - 初始化
-(void)setupUI{
    
    [self.contentView addSubview:self.bgContentView];
    
    [self.bgContentView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(self.contentView);
    }];
    
    LNHomeThemeItem *lastItem;
    CGFloat spece = (LN_SCREEN_WIDTH-280)/5;
    for (NSInteger i =0; i<4; i++) {
        LNHomeThemeItem *item = [LNHomeThemeItem themeItemWithTitle:@"标题" icon:@"AppIcon"];
        [self.bgContentView addSubview:item];
        if (lastItem) {
            [item mas_makeConstraints:^(MASConstraintMaker *make) {
                make.centerY.mas_equalTo(self.bgContentView);
                make.left.mas_equalTo(lastItem.mas_right).offset(spece);
                make.width.height.mas_equalTo(70);
            }];
        }
        else{
            [item mas_makeConstraints:^(MASConstraintMaker *make) {
                make.centerY.mas_equalTo(self.bgContentView);
                make.left.mas_equalTo(self.bgContentView).offset(spece);
                make.width.height.mas_equalTo(70);
            }];
        }
        lastItem = item;
    }
    
}

#pragma mark - setter and getter
-(UIView *)bgContentView{
    
    if(_bgContentView == nil){
        _bgContentView = [[UIView alloc] init];
    }
    return _bgContentView;
}
@end
